#ifndef TRANSPARENTOVERLAY_H
#define TRANSPARENTOVERLAY_H

#include <QDir>
#include <QTimer>
#include <QLabel>
#include <QWidget>
#include <QDialog>
#include <TcpServer.h>
#include <QThread>
#include <QShortcut>
#include <QFileDialog>
#include <QMediaPlayer>
#include <QListWidgetItem>
#include <QVideoWidget>
#include <QStackedWidget>

namespace Ui {
class TransparentOverlay;
}

class TransparentOverlay : public  QDialog
{
    Q_OBJECT

public:
    explicit TransparentOverlay(QMediaPlayer* player, QStackedWidget *StackedWidget, QLabel *ImageLabel = nullptr, QVideoWidget *VideoWidget = nullptr, QWidget *parent = nullptr);
    ~TransparentOverlay();

    void KeyTriggerSystem();
    void updateVideoPlayList(QString folderPath);
    void updateImagePlayList(QString folderPath);
    void defaultBackground();
    void videoStopDefaultImage();
    void imageLoading();
    void videoLoading();
    void radioButtonConnect();
    void updatePlayingState(QString fileName);

    void closeVideoWindow();
    void closeImageWindow();
    void tcpCmdSelect(QString filePathChild, QString fileName);
    void tcpCmdUpdate(QString fileUrl);

private slots:
    void on_play_clicked();

    //KeyTriggerSystem
    void onESCPressed();

    void on_pushButton_2_clicked();

    void on_back_clicked();

    void onItemMoved();

    void playSelectItem(QListWidgetItem *item);

    void on_pushButton_3_clicked();

    void onRadioButtonModelToggled(bool checked);
    void onRadioButtonVideoModelToggled(bool checked);
    void playPlanFunc(QMediaPlayer::MediaStatus status);

    void on_pushButton_clicked();

    void on_spinBox_valueChanged(int arg1);

    void onTimeout();

    void messageUpdate(QString message);

    void on_next_clicked();

private:
    Ui::TransparentOverlay *ui;
    QMediaPlayer *player;
    QLabel *imageLabel;
    QTimer *imageTimer;
    QVideoWidget *videoWidget;

    QStackedWidget *stackedWidget;

    bool playState = true;

    bool isPlaying;

    //播放index
    int currentFileIndex;
    int currentVideoFileIndex;
    int currentImageFileIndex;
    //播放列表
    QStringList videoFiles;
    QStringList ImageFiles;

    //当前播放的文件
    QString currentFilePath;

    // 路径选择
    QString filePath;

    // 定义模式
    enum class ShowMode
    {
        IMAGEVIEW,
        VIDEOVIEW,
        MIXMODE
    };

    // 定义播放模式的枚举
    enum class PlayMode {
        LISTLOOP,           // 列表循环
        SINGELLOOP,         // 单个循环
        SIGNELLOOPONCE,     // 单个循环一次
        LISTLOOPONCE        // 列表循环一次
    };
    PlayMode playMode;
    ShowMode showMode;

};

#endif // TRANSPARENTOVERLAY_H


